<html>
<head><meta charset="utf-8"><title>silencing only rustc lint warnings · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/silencing.20only.20rustc.20lint.20warnings.html">silencing only rustc lint warnings</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="228922338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/silencing%20only%20rustc%20lint%20warnings/near/228922338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matthiaskrgr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/silencing.20only.20rustc.20lint.20warnings.html#228922338">(Mar 05 2021 at 09:19)</a>:</h4>
<p>How can I disable (allow) all warnings coming from rustc but keep tool warnings on warn level?<br>
<code>RUSTFLAGS="-Awarnings" cargo clippy</code> silences all warnings but I want to keep the clippy warnings<br>
I also tried `RUSTFLAGS="-Arustc::warnings" cargo clippy``but that did not work either.</p>



<a name="228923010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/silencing%20only%20rustc%20lint%20warnings/near/228923010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matthiaskrgr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/silencing.20only.20rustc.20lint.20warnings.html#228923010">(Mar 05 2021 at 09:25)</a>:</h4>
<p>I'm working on an tool that auto-applies lint warnings via rustfix to spot false positives in clippy (show when applied suggestion breaks the build) but funky rustc suggestion seem to mess up my results <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="228951818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/silencing%20only%20rustc%20lint%20warnings/near/228951818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/silencing.20only.20rustc.20lint.20warnings.html#228951818">(Mar 05 2021 at 13:24)</a>:</h4>
<p>Does -Awarnings -Wclippy::all work?</p>



<a name="228951872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/silencing%20only%20rustc%20lint%20warnings/near/228951872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/silencing.20only.20rustc.20lint.20warnings.html#228951872">(Mar 05 2021 at 13:25)</a>:</h4>
<p>(Also, rustdoc warnings are tool warnings since a couple days ago)</p>



<a name="228952746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/silencing%20only%20rustc%20lint%20warnings/near/228952746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hyd-dev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/silencing.20only.20rustc.20lint.20warnings.html#228952746">(Mar 05 2021 at 13:30)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/silencing.20only.20rustc.20lint.20warnings/near/228951818">said</a>:</p>
<blockquote>
<p>Does -Awarnings -Wclippy::all work?</p>
</blockquote>
<p>No...</p>



<a name="228952840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/silencing%20only%20rustc%20lint%20warnings/near/228952840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hyd-dev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/silencing.20only.20rustc.20lint.20warnings.html#228952840">(Mar 05 2021 at 13:31)</a>:</h4>
<div class="codehilite" data-code-language="Bash Session"><pre><span></span><code><span class="gp">$ </span>clippy-driver --emit<span class="o">=</span>mir -o /dev/null - <span class="o">&lt;&lt;&lt;</span><span class="s1">'fn main() { loop {} }'</span>
<span class="go">warning: empty `loop {}` wastes CPU cycles</span>
<span class="go"> --&gt; &lt;anon&gt;:1:13</span>
<span class="go">  |</span>
<span class="go">1 | fn main() { loop {} }</span>
<span class="go">  |             ^^^^^^^</span>
<span class="go">  |</span>
<span class="go">  = note: `#[warn(clippy::empty_loop)]` on by default</span>
<span class="go">  = help: you should either use `panic!()` or add `std::thread::sleep(..);` to the loop body</span>
<span class="go">  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_loop</span>

<span class="go">warning: 1 warning emitted</span>

<span class="gp">$ </span>clippy-driver --emit<span class="o">=</span>mir -A warnings -W clippy::all -o /dev/null - <span class="o">&lt;&lt;&lt;</span><span class="s1">'fn main() { loop {} }'</span>
<span class="gp">$</span>
</code></pre></div>



<a name="228953102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/silencing%20only%20rustc%20lint%20warnings/near/228953102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hyd-dev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/silencing.20only.20rustc.20lint.20warnings.html#228953102">(Mar 05 2021 at 13:33)</a>:</h4>
<p>But <code>-D clippy::all</code> works:</p>
<div class="codehilite" data-code-language="Bash Session"><pre><span></span><code><span class="gp">$ </span>clippy-driver --emit<span class="o">=</span>mir -A warnings -D clippy::all -o /dev/null - <span class="o">&lt;&lt;&lt;</span><span class="s1">'fn main() { loop {} }'</span>
<span class="go">error: empty `loop {}` wastes CPU cycles</span>
<span class="go"> --&gt; &lt;anon&gt;:1:13</span>
<span class="go">  |</span>
<span class="go">1 | fn main() { loop {} }</span>
<span class="go">  |             ^^^^^^^</span>
<span class="go">  |</span>
<span class="go">  = note: `-D clippy::empty-loop` implied by `-D clippy::all`</span>
<span class="go">  = help: you should either use `panic!()` or add `std::thread::sleep(..);` to the loop body</span>
<span class="go">  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_loop</span>

<span class="go">error: aborting due to previous error</span>
</code></pre></div>



<a name="228953202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/silencing%20only%20rustc%20lint%20warnings/near/228953202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hyd-dev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/silencing.20only.20rustc.20lint.20warnings.html#228953202">(Mar 05 2021 at 13:34)</a>:</h4>
<p>But I haven't use <code>rustfix</code> before, so I don't know would denied warnings satisfy it.</p>



<a name="228953338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/silencing%20only%20rustc%20lint%20warnings/near/228953338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/silencing.20only.20rustc.20lint.20warnings.html#228953338">(Mar 05 2021 at 13:34)</a>:</h4>
<p>Oh that's so strange</p>



<a name="228953418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/silencing%20only%20rustc%20lint%20warnings/near/228953418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/silencing.20only.20rustc.20lint.20warnings.html#228953418">(Mar 05 2021 at 13:35)</a>:</h4>
<p>I guess you could do that and --cap-lints warn lol</p>



<a name="228953430"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/silencing%20only%20rustc%20lint%20warnings/near/228953430" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/silencing.20only.20rustc.20lint.20warnings.html#228953430">(Mar 05 2021 at 13:35)</a>:</h4>
<p>What a hack</p>



<a name="228953775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/silencing%20only%20rustc%20lint%20warnings/near/228953775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hyd-dev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/silencing.20only.20rustc.20lint.20warnings.html#228953775">(Mar 05 2021 at 13:37)</a>:</h4>
<p>Note that even if it works, user's lint settings will be overridden. (But it's fine if there's no "user's lint settings" or such settings can be detected and transformed to corresponding <code>-D</code> flags.)</p>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/silencing.20only.20rustc.20lint.20warnings/near/228953338">said</a>:</p>
<blockquote>
<p>Oh that's so strange</p>
</blockquote>
<p>It's <code>-A</code> <em><code>warnings</code></em>, not <code>-A warn-by-default-lints</code> or <code>-A previously-specified-warnings</code>, isn't it? <code>-D clippy::all</code> makes it an error.</p>



<a name="228979845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/silencing%20only%20rustc%20lint%20warnings/near/228979845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matthiaskrgr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/silencing.20only.20rustc.20lint.20warnings.html#228979845">(Mar 05 2021 at 16:17)</a>:</h4>
<p>mmh doesn't look like rustfix likes the hacks... <span aria-label="sweat" class="emoji emoji-1f613" role="img" title="sweat">:sweat:</span> <br>
<code>RUSTFLAGS="-Awarnings -Wclippy::all" cargo clippy -Zunstable-options --fix</code> doesn't work either  (code isn't changed at all)</p>



<a name="228986701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/silencing%20only%20rustc%20lint%20warnings/near/228986701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hyd-dev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/silencing.20only.20rustc.20lint.20warnings.html#228986701">(Mar 05 2021 at 16:56)</a>:</h4>
<p>I'm not sure if this hack is desirable:</p>
<div class="codehilite" data-code-language="Bash"><pre><span></span><code>rustc -W <span class="nb">help</span> <span class="p">|</span> sed -nE <span class="s1">'s/^ *([a-z-]+)  (allow|warn|deny).+/-A\1/p'</span>
</code></pre></div>
<p>Note that it will hit the <code>unsafe_block_in_unsafe_fn</code> feature gate, that needs to be workarounded somehow, maybe by using <code>-Zcrate-attr=feature(unsafe_block_in_unsafe_fn)</code>, or filtering <code>-Aunsafe-op-in-unsafe-fn</code> from that option list out.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>